"""
@Author  : 刘文豪
@desc    : 后台首页
@Time    : 2025/8/10
"""
import time

from base.base import Base
from selenium.webdriver.common.by import By

from util import GetLog
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class PageIndex(Base):
    def __init__(self,driver):
        super(PageIndex,self).__init__(driver)
        self.driver = driver
        self.logger = GetLog.get_log()
        # 元素初始化
        self.el_title = (By.XPATH, "//div[@title='制造与供应链管控平台']") # 左上角标题，判断登录成功
        self.el_gy_app = (By.XPATH, "(//img)[16]")# 供应应用
        self.el_mfg_cell_menu = (By.XPATH, "//li[@role='menuitem']//span[contains(text(),'执行单元')]")  # 制造管理单元菜单下拉框下的执行单元


    # 跳转点击到执行单元页面
    def page_jump_gy(self):
        try:
            # 等待元素可点击并点击
            self.base_click_u(self.el_gy_app)
            self.logger.info("首页-点击供应应用-成功")
            time.sleep(3)
        except Exception as e:
            self.logger.error(e)
            self.logger.error("首页-操作元素失败")

    # 获取右上角登录名值
    def get_value(self):
        return  self.base_get_value(self.el_title)
